<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center platformMessage_flex_0"
			:style="{height:(64+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub platformMessage_fd0_0'>
				<view class='flex flex-wrap align-center platformMessage_fd0_0_c0'
					@tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  platformMessage_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-center'>
					<text class='platformMessage_fd0_0_c1_c0'>平台消息</text>
				</view>
				<view class='flex flex-wrap align-center platformMessage_fd0_0_c0'>
				</view>
			</view>

		</view>
		<view :style="{height: (64+StatusBarRpx)+'rpx'}"></view>

		<view class="flex flex-direction align-stretch benben-flex-layout platformMessage_flex_1">
			<view class="tabs">
				<view class="tabs_item" :class="tabs == 1 ? 'active_item' : ''" @tap.stop="selectTabs(1)">
					<text>强化提醒</text>
					<text class="tabs_line" v-if="tabs == 1"></text>
				</view>
				<view class="tabs_item" :class="tabs == 2 ? 'active_item' : ''" @tap.stop="selectTabs(2)">
					<text>平台公告</text>
					<text class="tabs_line" v-if="tabs == 2"></text>
				</view>
			</view>
			
			<view class="loading_css" v-if="isShow">
				<uv-loading-icon size="24" mode="circle" color="#4087FD" :show="true"></uv-loading-icon>
				<view>加载中</view>
			</view>
			
			<template v-else>
				<template v-if="tabs == 1">
					<view class="intensify" v-for="(v, k) in systemList" :key="k" @tap.stop="goDetails(k)">
						<view class="intensify_item">
							<view class="item_title">
								<view class="">{{v.title}}</view>
								<view class="date_text">{{v.create_time_text}}</view>
							</view>
							<view class="item_content">
								<view class="item_content_1">
									{{v.content}}
								</view>
								<image class="item_content_2" :src='STATIC_URL+"12.png"' mode=""></image>
							</view>
						</view>
					</view>
					<view class="loadmore" v-if="last_page > 1">
						<uv-load-more :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText"
							:nomore-text="nomoreText" />
					</view>
					<view class="noData" v-if="systemList.length == 0 && !isShow">
						<image :src='STATIC_URL+"no.png"'></image>
					</view>
				</template>
				<template v-if="tabs == 2">
					<view class='flex flex-direction align-stretch platformMessage_fd1_0' @tap.stop="handleJumpDiy"
						data-type="navigateTo" :data-url="`/pages/main/messageDetails/messageDetails?aid=${item.aid}`" v-for='(item,key0) in list' :key='key0'>
						<view class='platformMessage_fd1_0_c0 flex flex-wrap align-center justify-between'>
							<text>{{item.title}}</text>
							<text class='platformMessage_fd1_0_c2'>{{item.create_time}}</text>
						</view>
						<view class='platformMessage_fd1_0_c1'>{{item.content}}</view>
						<view class="content_img" v-if="item.thumb">
							<image :src='item.thumb' mode=""></image>
						</view>
					</view>
					<view class="loadmore" v-if="last_page > 1">
						<uv-load-more :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText"
							:nomore-text="nomoreText" />
					</view>
					<view class="noData" v-if="list.length == 0 && !isShow">
						<image :src='STATIC_URL+"no.png"'></image>
					</view>
				</template>
			</template>
			

		</view>

	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
import { url } from '../../../uni_modules/uv-ui-tools/libs/function/test';
	export default {
		components: {},


		data() {
			return {
				"systemList": [],
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"loadingText": '努力加载中',
				"loadmoreText": '轻轻上拉',
				"nomoreText": '没有更多了',
				"isShow": true,
				"tabs": 1,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			if (this.tabs == 1) {
				this.getsystem();
			} else if (this.tabs == 2) {
				this.getList();
			}
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.is_pull = true;
			this.isShow = true;
			this.getList();
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.is_pull = false;
				this.getList();
			}, 500)
		},
		onPageScroll(e) {

		},
		methods: {
			selectTabs(type) {
				this.tabs = type;
				this.page = 1;
				this.is_pull = true;
				this.isShow = true;
				if (type == 1) {
					this.getsystem();
				} else if (type == 2) {
					this.getList();
				}
			},
			// 获取系统通知  post6424280846288
			getsystem() {
				this.$api.post(global.apiUrls.post6424280846288, {
					msg_type: 1,
					page: this.page
				}).then(res => {
					console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.systemList = res.data.data.data;
						} else {
							this.systemList = this.systemList.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			goDetails(index) {
				// jump_id
				// 跳转类型jump_type  1 ：单词海马体1 抗遗忘页面  2：单词海马体2 抗遗忘训练词汇记录  3单词海马体3单词强化  4演讲背诵海马体1强化详情  5演讲背诵海马体2强化详情  6陪看海马体1   7陪看海马体2   8文章闯关
				if (this.systemList[index].jump_type == 1) {
					uni.navigateTo({
						url: '/pages/index/antiForget/wordReinforcement?aid=' + this.systemList[index].jump_id + '&data_type=1'
					})
				} else if (this.systemList[index].jump_type == 2) {
					uni.navigateTo({
						url: '/pages/index/antiForget/wordReinforcement?aid=' + this.systemList[index].jump_id + '&data_type=2'
					})
				} else if (this.systemList[index].jump_type == 3) {
					uni.navigateTo({
						url: '/pages/index/antiForget/wordSummary?aid=' + this.systemList[index].jump_id
					})
				} else if (this.systemList[index].jump_type == 4) {
					uni.navigateTo({
						url: '/pages/index/antiForget/articleDetails?aid=' + this.systemList[index].jump_id + '&type=1&is_record=1'
					})
				} else if (this.systemList[index].jump_type == 5) {
					uni.navigateTo({
						url: '/pages/index/antiForget/articleDetails?aid=' + this.systemList[index].jump_id + '&type=2'
					})
				} else if (this.systemList[index].jump_type == 6) {
					uni.navigateTo({
						url: '/pages/index/antiForget/watchOneDetails?aid=' + this.systemList[index].jump_id + '&isDetails=1'
					})
				} else if (this.systemList[index].jump_type == 7) {
					uni.navigateTo({
						url: '/pages/index/antiForget/watchOneDetails?aid=' + this.systemList[index].jump_id + '&isDetails=1'
					})
				} else if (this.systemList[index].jump_type == 8) {
					uni.navigateTo({
						url: '/pages/index/breakBarrier/challengeDetails?aid=' + this.systemList[index].jump_id
					})
				}
				
			},
			
			
			// 获取平台公告列表  post6415752f56d0f
			getList() {
				this.$api.post(global.apiUrls.post6415752f56d0f, {
					page: this.page
				}).then(res => {
					// console.log(res);
					uni.stopPullDownRefresh();
					this.isShow = false;
					if (res.data.code == 1) {
						this.last_page = res.data.data.last_page;
						if (this.is_pull) {
							this.list = res.data.data.data;
						} else {
							this.list = this.list.concat(res.data.data.data);
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
		}
	};
</script>
<style lang="scss" scoped>
	.intensify {
		padding: 0 25rpx;
		.intensify_item {
			padding: 20rpx 0;
			border-bottom: 1px solid #eee;
			.item_title {
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 20rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				color: #333333;
				.date_text {
					font-size: 18rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
			.item_content {
				display: flex;
				align-items: center;
				margin-top: 10rpx;
				.item_content_1 {
					width: calc(100% - 16rpx);
					font-size: 18rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
				.item_content_2 {
					width: 10rpx;
					height: 15rpx;
				}
			}
		}
	}
	.tabs {
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0rpx 135rpx;
		.tabs_item {
			font-size: 20rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			color: #333333;
			padding: 20rpx 0;
			position: relative;
		}
		.active_item {
			color: #4087FD;
			font-weight: bold;
		}
		.tabs_line {
			display: inline-block;
			width: 31rpx;
			height: 5rpx;
			background: #4087FD;
			border-radius: 6rpx;
			position: absolute;
			left: 50%;
			bottom: 0;
			transform: translateX(-50%);
		}
	}
	.content_img {
		width: 100%;
		height: 219rpx;
		margin-top: 20rpx;
		image {
			width: 100%;
			height: 100%;
			border-radius: 10rpx;
		}
	}
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(248, 248, 248, 1);
		background-size: 100% auto !important;
	}

	.platformMessage_flex_0 {
		background: #fff;
		width: 100%;
		height: 64rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.platformMessage_fd0_0_c1_c0 {
		font-size: 25rpx;
		font-weight: 500;
		color: #333333;
		line-height: 64rpx;
	}

	.platformMessage_fd0_0_c0_c0 {
		font-size: 25rpx;
		color: #333;
	}

	.platformMessage_fd0_0_c0 {
		width: 50rpx;
		height: 50rpx;
	}

	.platformMessage_fd0_0 {
		padding: 0rpx 25rpx 0rpx 25rpx;
	}

	.platformMessage_flex_1 {
		margin: 16rpx 25rpx 16rpx 25rpx;
		background: #fff;
		border-radius: 10rpx;
	}

	.platformMessage_fd1_0_c2 {
		font-size: 18rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 25rpx;
	}

	.platformMessage_fd1_0_c1 {
		margin: 10rpx 0rpx 0rpx 0rpx;
		font-size: 18rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 26rpx;
		// -webkit-line-clamp: 2;
		// overflow: hidden;
		// text-overflow: ellipsis;
		// display: -webkit-box;
		// -webkit-box-orient: vertical;
	}

	.platformMessage_fd1_0_c0 {
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #333333;
		// line-height: 45rpx;
		// -webkit-line-clamp: 1;
		// overflow: hidden;
		// text-overflow: ellipsis;
		// display: -webkit-box;
		// -webkit-box-orient: vertical;
	}

	.platformMessage_fd1_0 {
		// background: #fff;
		width: 100%;
		padding: 20rpx 25rpx 20rpx 25rpx;
		// border-bottom: 1px solid #eee;
	}
</style>